#ifndef CONFIGURE_H
#define CONFIGURE_H

#include <map>
#include <string>
#include <cstdio>

using std::map;
using std::string;

class Configure {
public:
    Configure(const char *dir, const char *fname, char assign_symbol);

    Configure(const char *fname, char assign_symbol);

    ~Configure();

    const char * operator[](const char *key);
    const char * operator[](const string &key);

private:
    /* 配置文件路径 */
    char *fpath;

    /* 配置文件句柄 */
    FILE *fin;

    /* 赋值符号 */
    char assign_symbol;

    map<string, string> data_map;

    void read_configure();

    bool get_key_value(const char *str, char *&key, char *&value);
};

#endif // CONFIGURE_H
